<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <ul>
    <li>Hello world!</li>
    <li>Hello world! 2</li>
    <li>Hello world! 3</li>
    <li>Hello world! 4</li>
    <li>Hello world! 5</li>
    <li>Hello world! 6</li>
    <li>Hello world! 7</li>
  </ul>

  <script>
    /**
     * 需要给多个元素注册事件监听时，可以给它们的共同父元素注册事件监听，通过事件对象的 target 区分事件源
     * 
     * 原理
     *  ● 事件冒泡
     *  ● 事件对象
     */
    document.querySelector('ul').addEventListener('click', function (event) {
      event = event || window.event
      const target = event.target || event.srcElement

      console.log(target.innerText)
    })
  </script>
</body>

</html>